package co.baiku.boot.response;

import co.baiku.boot.request.WeixinPayRequest;
import co.baiku.boot.type.WeixinCodeType;

import java.util.HashMap;
import java.util.Map;

public class WeixinMsgResponse implements WeixinPayRequest {

    /**
     * SUCCESS/FAIL 此字段是通信标识，非交易标识，交易是否成功需要查看result_code来判断
     */
    private String return_code;
    /**
     * 返回信息，如非空，为错误原因签名失败参数格式校验错误
     */
    private String return_msg;

    public static WeixinMsgResponse fail(String msg) {
        WeixinMsgResponse response = new WeixinMsgResponse();
        response.setReturn_code(WeixinCodeType.FAIL.name());
        response.setReturn_msg(msg);
        return response;
    }

    public static WeixinMsgResponse success() {
        WeixinMsgResponse response = new WeixinMsgResponse();
        response.setReturn_code(WeixinCodeType.SUCCESS.name());
        return response;
    }


    public String getReturn_code() {
        return return_code;
    }

    public void setReturn_code(String return_code) {
        this.return_code = return_code;
    }

    public String getReturn_msg() {
        return return_msg;
    }

    public void setReturn_msg(String return_msg) {
        this.return_msg = return_msg;
    }

    @Override
    public Map<String, String> toMap() {
        Map<String, String> map = new HashMap<>();
        map.put("return_code", return_code);
        map.put("return_msg", return_code);
        return map;
    }
}
